package kafka_manager

import (
	"gitee.com/zaper/kafka-service/kafka_consumer"
	"gitee.com/zaper/kafka-service/kafka_consumer/kafka_consumer_model"
	"gitee.com/zaper/private-logger"
)

func InitializeConsumer(consumerModel *kafka_consumer_model.ConsumerModel, consumer kafka_consumer.ConsumerInterface) {
	agent := kafka_consumer.NewConsumerAgent()
	// 订阅
	err := agent.ConsumerSub(consumerModel)
	if err != nil {
		logger.Errorf("kafka consumerSub fail")
		return
	}

	// 消费
	messChan, err := agent.ConsumerMess()
	if err != nil {
		logger.Errorf("kafka Consumer mess fail")
		return
	}
	consumer.ConsumerMessage(messChan)
}
